package com.crm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.crm.pojo.domain.Business;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface BusinessMapper extends BaseMapper<Business> {
    /**
     * 获取指定商机的最新下次跟进时间
     * @param businessId 商机ID
     * @return 最新下次跟进时间
     */
    @Select("SELECT `next_time` FROM `business` WHERE `id` = #{businessId}")
    String getLatestNextTime(@Param("businessId") Integer businessId);

    @Update("update business set finish_time = NOW() where id = #{id}")
    void endById(Integer id);
    @Update("update business set status = 2 where id = #{businessId}")
    void genjin(Integer businessId);

    void transfer(Long oldId, Long newId);
}